package com.zjkj.mp.dao.customer.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.zjkj.mp.dao.DaoBase;
import com.zjkj.mp.dao.customer.CustomerManagerDAO;
import com.zjkj.mp.utils.PaginatedResult;
import com.zjkj.mp.vo.customer.ContactPerson;
@Repository
public class CustomerManagerDAOImpl extends DaoBase implements CustomerManagerDAO {

	public int createContactPersonDAO(ContactPerson person) throws Exception {
		
		return this.getSqlMapClient().update("createPerson", person);
	}

	public PaginatedResult findContactPersonList(Map<String, String> map)
			throws Exception {
		PaginatedResult result = new PaginatedResult();
		result.setCurrPage(Integer.parseInt(map.get("pageNo")));
		result.setPageSize(Integer.parseInt(map.get("pageSize")));
		int total = (Integer) this.getSqlMapClient().queryForObject("findContactPersonListCount",map);
		result.setTotalSize(total);
		List<ContactPerson> p = this.getSqlMapClient().queryForList("findContactPersonList",map, (Integer.parseInt(map.get("pageNo"))-1)*10, 10);
		result.setResult(p);
		return result;
	}
	
	public List<ContactPerson> getContactPersonList(Map<String, Object> map){
		return getSqlMapClient().queryForList("get.contactPersonList", map);
	}

	public ContactPerson findConcatePersonByParm(Map<String, String> map)
			throws Exception {
		ContactPerson person = (ContactPerson) this.getSqlMapClient().queryForObject("findConcatePersonByParm", map);
		return person;
	}

	public int updateConcatePerson(ContactPerson person) throws Exception {
		
		return this.getSqlMapClient().update("updateConcatePerson", person);
	}

	public int deleteConcatePerson(Map<String, String> map) throws Exception {
		
		return this.getSqlMapClient().delete("deleteConcatePerson",map);
	}

	public PaginatedResult findConcatePersonList(Map<String, String> map) throws Exception {
		PaginatedResult result = new PaginatedResult();
		result.setCurrPage(Integer.parseInt(map.get("pageNo")));
		result.setPageSize(Integer.parseInt(map.get("pageSize")));
		int total = (Integer) this.getSqlMapClient().queryForObject("ContactPersonListByParamCount",map);
		result.setTotalSize(total);
		List<ContactPerson> p = this.getSqlMapClient().queryForList("ContactPersonListByParam",map, (Integer.parseInt(map.get("pageNo"))-1)*10, 10);
		result.setResult(p);
		return result;
	}

}

/**
 * Copyright © 2013,指尖科技 All rights reserved.
 */